import { createVuePlugin } from 'vite-plugin-vue2'
import { resolve } from 'path'
import eslintPlugin from 'vite-plugin-eslint'
export default {
  envDir:'./viteEnv',
  plugins: [
    createVuePlugin(),
    eslintPlugin({
      include: ['src/**/*.js', 'src/**/*.vue', 'src/*.js', 'src/*.vue']
    })],
  // 静态资源服务的文件夹
  publicDir: 'public',
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  server: {
    host: '0.0.0.0',
    // 端口号
    port: 8088,
    open:'index.html',
    https: false,
    hot: true,
    disableHostCheck: true,
    // 设置为 true 强制使依赖预构建
    force: true,
    proxy: {
      '/api': {
        target: 'https://ctc.panda.org.cn/api/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },

    },
    // 禁用或配置 HMR 连接
    hmr: {},
    // 传递给 chokidar 的文件系统监视器选项
    watch: {}
  },
  // 构建
  build: {
    target: 'modules',
    // 指定输出路径
    outDir: 'dist',
    // 指定生成静态资源的存放路径
    assetsDir: 'assets',
    rollupOptions: {
      output: {
        chunkFileNames: 'assets/js/[name]-[hash].js',
        entryFileNames: 'assets/js/[name]-[hash].js',
        assetFileNames: 'assets/[ext]/[name]-[hash].[ext]'
      }
    }
  },
  css: {
    preprocessorOptions:{
      scss: {
        additionalData: '@import "@/assets/css/mixin.scss";'
      }
    }
  }
}
